package com.thread.sychronized;

/**
 * @author wangyingjie
 * @date
 * @remark 模拟存钱进程
 */
public class AccountDepositThread extends Thread{

    private Account account;

    private double money;

    /**
     * 有参构造保证是同一个账户
     * @param account
     * @param money
     */
    public AccountDepositThread(Account account, double money) {
        this.account = account;
        this.money = money;
    }

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            try {
                account.deposit(money);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
